import Token
import Editor
import string
import CmdNo
from Register import RegisterKeys
def InitEmacsKeymap(kh):
	kh.BindKey("C-v",Editor.PageDown)
	kh.BindKey("Esc v",Editor.PageUp)

	kh.BindKey("Esc z AnyOtherKey",kh.Zap)

	kh.BindKey('Esc u',Editor.Upcase)
	kh.BindKey('Esc l',Editor.Downcase)
	kh.BindKey('Esc c',Editor.Capitalize)

#	kh.BindKey("Esc x",kh.Readlines)

	kh.BindKey("C-x C-x",Editor.Cut)
	kh.BindKey("C-x C-c",Editor.Copy)
	kh.BindKey("C-x C-v",Editor.Paste)

	kh.BindKey("C-/",Editor.Undo)
	kh.BindKey("C-?",Editor.Redo)

	kh.BindKey("C-g",kh.Cancel)
	kh.BindKey("Esc g",kh.Cancel)
#	kh.BindKey("C-h",kh.ToggleHelp)

	# File Menu
	kh.SetShortcut("C-x C-f",CmdNo.cLOAD)	# "Load..."
	kh.SetShortcut("C-x C-r",CmdNo.cREVERT)	# "Revert..."
	kh.SetShortcut("C-x C-s",CmdNo.cSAVE)	# "Save@S"
##	kh.SetShortcut("M-?",CmdNo.cSAVEAS)	# "Save As..."
##	kh.SetShortcut("M-?",CmdNo.cREVERT)	# "Revert"

	kh.SetShortcut("C-c o",CmdNo.cIdRccsCheckOut)	# "Check Out...@O"
	kh.SetShortcut("C-c i",CmdNo.cIdRccsCheckIn)	# "Check In...@I"
##	kh.SetShortcut("M-?",CmdNo.cIdDiffVersion)	# "Show Differences..."

##	kh.SetShortcut("M-?",CmdNo.cPRINT)	# "Print..."

	# Edit Menu

	kh.SetShortcut("C-c z",CmdNo.cUNDO)	# "Undo@Z"
##	kh.SetShortcut("M-?",CmdNo.cREDO)	# "Redo"

	kh.SetShortcut("C-c x",CmdNo.cCUT)		# "Cut@X"
	kh.SetShortcut("C-c c",CmdNo.cCOPY)	# "Copy@C"
	kh.SetShortcut("C-c v",CmdNo.cPASTE)	# "Paste@V"
##	#kh.SetShortcut("M-?",CmdNo.cIMPORT)	# "Paste File..."

	kh.SetShortcut("C-c a",CmdNo.cSELECTALL)		# "Select All@A"
	kh.SetShortcut("C-c n",CmdNo.cIdNest)	# "Nest@N"
	kh.SetShortcut("C-c u",CmdNo.cIdUnNest)		# "Unnest@U"
##	kh.SetShortcut("M-?",CmdNo.cIdComment)		# "Comment"
##	kh.SetShortcut("M-?",CmdNo.cIdUnComment)		# "Uncomment"

	## Positioning
	kh.SetShortcut("C-c t",CmdNo.cIdShowSymbol)	# "@T"
##	kh.SetShortcut("M-?",CmdNo.cIdEditSuperClass)		# ""
##	kh.SetShortcut("M-?",CmdNo.cIdEditPreviousMethod)	# ""
	kh.SetShortcut("C-c e",CmdNo.cIdToggleForSymbol)		# "@E"
	kh.SetShortcut("C-c e",CmdNo.cIdEditSel)		# "Edit Definition@E"
	kh.SetShortcut("C-c e",CmdNo.cIdEditImpl)		# "@E"

	kh.SetShortcut("C-c p",CmdNo.cIdPreviousPosition)		# "Previous Position@P"

	kh.SetShortcut("C-c f",CmdNo.cFIND)	# "Find/Change...@F"
	kh.SetShortcut("C-c g",CmdNo.cFINDAGAIN)		# "Find Again@G"
	kh.SetShortcut("C-c >",CmdNo.cIdFindSelectionForward)	# "Search Forward@>"
	kh.SetShortcut("C-c <",CmdNo.cIdFindSelectionBackward)	# "Search Backward@<"
	kh.SetShortcut("C-c l",CmdNo.cGOTOLINE)		# "Go To Line...@L"
##	kh.SetShortcut("C-c r",CmdNo.cIdNextMatch)		# "Next Match@R"


	## Utilities
##	kh.SetShortcut("M-?",CmdNo.cIdUpdateSymtab)	# "Update Symbol Table"
##	kh.SetShortcut("M-?",CmdNo.cIdSwitchCont)	# "Show Symbols"

	## Make
##	kh.SetShortcut("M-?",CmdNo.cIdMakeFile)		# "Make File"
	kh.SetShortcut("C-c m",CmdNo.cIdMakeDir)		# "Make Project@M"
##	kh.SetShortcut("M-?",CmdNo.cIdMake)	# "Make All Writable Projects"
##	kh.SetShortcut("M-?",CmdNo.cIdGenMakeFile)	# "Update Makefiles"

	## info
	kh.SetShortcut("C-c 2",CmdNo.cIdRetrieveCurrent)		# "Retrieve @2"
##	kh.SetShortcut("M-?",CmdNo.cIdRetrieveTopLevel)		# "Retrieve From Current Project"
##	kh.SetShortcut("M-?",CmdNo.cIdRetrieveAll)	# "Retrieve From All Subprojects"
##	kh.SetShortcut("M-?",CmdNo.cIdRetrieveFromFile)	# "Retrieve From This File"

	kh.SetShortcut("C-c 1",CmdNo.cIdFindMatchingSyms)		# "Find Symbols Matching@1"
##	kh.SetShortcut("M-?",CmdNo.cIdFindContainingSyms)	# "Find Symbols Containing"

	kh.SetShortcut("C-c c",CmdNo.cIdCopySelection)	# "Copy Selected String @C"

##	kh.SetShortcut("M-?",CmdNo.cIdDocu)	# "Show Documentation Of"
####	kh.SetShortcut("M-?",CmdNo.cIdMarkDocu)		# "Mark Documented"

	## Class
	kh.SetShortcut("C-c b",CmdNo.cIdBrowseSel)	# "Browse@B"
##	kh.SetShortcut("M-?",CmdNo.cIdClassInHierarchy) # "Show in Hierarchy"
##	kh.SetShortcut("M-?",CmdNo.cIdClassInRestrHierarchy) # "Show in Restricted Hierarchy"

	## exec menu
##	kh.SetShortcut("C-c n",CmdNo.cEXC_NEXT)		# "Next@N"
##	kh.SetShortcut("C-c s",CmdNo.cEXC_STEP)		# "Step@S"
##	kh.SetShortcut("M-?",CmdNo.cEXC_RUN)	# "Run"
	kh.SetShortcut("C-c c",CmdNo.cEXC_CONT)		# "Cont@C"
##	kh.SetShortcut("M-?",CmdNo.cEXC_FINISH)		# "Step Out"
##	kh.SetShortcut("M-?",CmdNo.cEXC_KILL)		# "Interrupt"

##	kh.SetShortcut("M-?",CmdNo.cFILE_ADDSYM)		# "Add Symbols"

	kh.SetShortcut("C-c d",CmdNo.cIdDebugTarget)	# "Debug Target@D"
##	kh.SetShortcut("M-?",CmdNo.cFILE_DONE)		# "End Debugsession"
##	kh.SetShortcut("M-?",CmdNo.cFILE_KILL)		# "Quit Debugger"

	## inspect
##	kh.SetShortcut("M-?",CmdNo.cPRT_SELPTR)		# "Print *"
##	kh.SetShortcut("M-?",CmdNo.cPRT_SELMEMPTR)	# "Print *this->"
##	kh.SetShortcut("M-?",CmdNo.cPRT_SELMEM)		# "Print this->"
##	kh.SetShortcut("M-?",CmdNo.cPRT_THIS)		# "Print *this"

##	kh.SetShortcut("M-?",CmdNo.cDISP_SEL)		# "Display"
##	kh.SetShortcut("M-?",CmdNo.cDISP_SELPTR)		# "Display *"
##	kh.SetShortcut("M-?",CmdNo.cDISP_SELMEMPTR)	# "Display *this->"
##	kh.SetShortcut("M-?",CmdNo.cDISP_SELMEM)		# "Display this->"
##	kh.SetShortcut("M-?",CmdNo.cDISP_THIS)		# "Display *this"
##	kh.SetShortcut("M-?",CmdNo.cDISP_UNDISP)		# "Undisplay"

##	kh.SetShortcut("M-?",CmdNo.cINSP_THIS)		# "Inspect this"
##	kh.SetShortcut("M-?",CmdNo.cINSP_SEL)		# "Inspect"
##	kh.SetShortcut("M-?",CmdNo.cINSP_SELMEM)		# "Inspect this->"

####	kh.SetShortcut("C-c l",CmdNo.cGOTOLINE)
####	kh.SetShortcut("C-x C-s",CmdNo.cSAVE)
####	kh.SetShortcut("C-x C-t",CmdNo.cSAVE)
####	kh.SetShortcut("C-c o",CmdNo.cIdRccsCheckOut)
####	kh.SetShortcut("C-c i",CmdNo.cIdRccsCheckIn)
####							
####	kh.SetShortcut("C-c x",CmdNo.cCUT)
####	kh.SetShortcut("C-c c",CmdNo.cCOPY)
####	kh.SetShortcut("C-c v",CmdNo.cPASTE)
####	kh.SetShortcut("C-c a",CmdNo.cSELECTALL)
####	kh.SetShortcut("C-c n",CmdNo.cIdNest)
####	kh.SetShortcut("C-c u",CmdNo.cIdUnNest)
####	kh.SetShortcut("C-c f",CmdNo.cFIND)
####	kh.SetShortcut("C-c g",CmdNo.cFINDAGAIN)


##	kh.SetShortcut("C-w",CmdNo.cCLOSE)
RegisterKeys(InitEmacsKeymap,"")
